<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>展开语法</title>
</head>
<body>
    <script type="text/javascript">

    // 数组 ——————————————————————————————————————

     let arr = [4,5,6,7]
     console.log(arr); // (5) [1, 3, 5, 7, 9]
     console.log(...arr); // 1 3 5 7 9  （拆包）
     
     function demo(...params){ // 打包
        console.log('我收到的参数为：', params);
    }
    demo(1,2,3)
    
    let arr2 = [1,2,3,...arr,8] // 拆包
    console.log(arr2);// (8) [1, 2, 3, 4, 5, 6, 7, 8]

    // 对象 ——————————————————————————————————————

    let obj = {name:'圆圆的海峰',age:18,sex:'女'}
    let obj2 = {nationality:'Chinese',height:'180cm'}
    console.log(obj); // {name:'圆圆的海峰',age:18,sex:'女'}
    console.log({...obj,...obj2}); // {name: '圆圆的海峰', age: 18, sex: '女', nationality: 'Chinese', height: '180cm'}
    console.log({...obj,name:'LX'}); // {name: 'LX', age: 18, sex: '女'}
    </script>
</body>
</html>